<?php
namespace app\admin\validate;

use think\Validate;

class User extends Validate
{
    protected $rule = [
        'username'         => 'require|unique:user|usernameRegex|min:4',
        'password'         => 'min:6',
        'mobile'           => 'number|unique:user|length:11',
        'email'          => 'email',
    ];
    protected $regex = [
        'usernameRegex'    => '/^[a-zA-Z][A-Za-z0-9]+$/'
    ];
    protected $message = [
        'username.require'         => '请输入用户名',
    	'username.min'         => '用户名至少2位',
        'username.unique'          => '用户名已存在',
        'password.length'         => '密码不小于6位',
        'mobile.number'            => '手机号格式错误',
        'mobile.length'            => '手机号长度错误',
        'username.usernameRegex'     => '用户名只能含有字母或数字且只能以字母开头',
        'email.email'              => '邮箱格式错误',
    ];
}